﻿<?php
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
include("../smarty/main.php");  
require_once("phpfile/connetMysql.class.php"); 
require_once("phpfile/db_comment_content.php"); 
error_reporting(E_ALL & ~E_NOTICE);
if(isset($_GET['newsid']) && $_GET['newsid'] != ""){
	$newsid=$_GET['newsid'];
	$newstitle="";
	$newscontent="";
	$newsbrowsenumber="";
	$newssubmittime="";
	$newscommentnumber="";

	$db=new connetMysql;
	$con=$db->getConnect();
	//////////查询新闻表
	$sql_news="SELECT * FROM newsdraft where newsid='".$newsid."'";
	$result_news = mysqli_query($con,$sql_news); 
	if($row_news = mysqli_fetch_array($result_news)){
		if($row_news['newsstate']=="1"){
			$newstitle=$row_news["newstitle"];
			$newscontent=$row_news["newscontent"];
			$newsbrowsenumber=$row_news["newsbrowsenumber"];	
			$newssubmittime=$row_news["newssubmittime"];	
			$newsuserid=$row_news["newsname"];
			$username="";
			/////////////查询新闻发布名字
			$sql_newsusername="SELECT * FROM user where userid='$newsuserid'";
			$result_newsusername = mysqli_query($con,$sql_newsusername);
			if($row_username = mysqli_fetch_array($result_newsusername)) {
				$username=$row_username['username'];
			}
			
			
			/////////查询评论个数
			$sql_commentnumber="SELECT * FROM comment where commentnewsid='$newsid'";
			$result_commentnumber = mysqli_query($con,$sql_commentnumber); 
			$newscommentnumber=mysqli_num_rows($result_commentnumber);

			$commentnewscontent="";
			$pinglun_time_more="";
			$pinglun_my_more="";

			$sql_commentcontent="SELECT * FROM comment where commentnewsid='$newsid' ORDER BY commenttime DESC LIMIT 0,5";
			$comment=new db_comment;
			$commentnewscontent=$comment->commentcontent($sql_commentcontent);
			if($commentnewscontent==""){
				$commentnewscontent="<div class='nomore_comment_content'>没有更多评论~</div>";
				$pinglun_time_more="<a href='javascript:void(0);'>加载更多</a>";
				$pinglun_my_more="<a href='javascript:void(0);'>加载更多</a>";
			}
			else{
				$pinglun_time_more="<a href='javascript:void(0);' onclick='js_pinglun_time_more(".$newsid.")'>加载更多</a>";
				$pinglun_my_more="<a href='javascript:void(0);' onclick='js_pinglun_my_more(".$newsid.")'>加载更多</a>";
			}
			$tpl->assign("get_newsid", $newsid);  ////////////把新闻ID放到某个位置，然后获取新闻ID
			$tpl->assign("pinglun_time_more", $pinglun_time_more);  
			$tpl->assign("pinglun_my_more", $pinglun_my_more); 
			$tpl->assign("commentnewscontent", $commentnewscontent);  
			//$tpl->assign("comment_pinglun_number", $newscommentnumber); 

			$tpl->assign("current_locat", "当前位置>新闻内容页");  
			$tpl->assign("news_title", $newstitle);  
			$tpl->assign("news_fabu_time", $newssubmittime);  
			$tpl->assign("news_fabu_name", $username);  
			$tpl->assign("news_comment_canyu", $newsbrowsenumber);  
			$tpl->assign("news_comment_pinglun", $newscommentnumber);  
			$tpl->assign("display_content", $newscontent);

			$tpl->display("display_news.html");
		}
		else{
			echo "页面不存在！";
		}
	}
	else{
		echo "页面不存在！";
	}
	
	
	
}             //////////////////结束     if(isset($_GET['newsid']) && $_GET['newsid'] != "")
else{
	echo "页面不存在！";
}
?>